/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.dao;

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;


/**
 * ClassName: BaseDao <br/> 
 * Function: dao层的基准类 <br/> 
 * date: 2017年11月1日 下午2:32:41 <br/> 
 * 
 * @author wd
 * @version @param <T> 
 * @since JDK 1.8 
 */
public class BaseDao {
	private static final String URL="jdbc:mysql://localhost:3306/train?characterEncoding=utf8&useSSL=true";
	private static final String USERNAME="root";
	private static final String USERPASS="root";
	private static final String DRIVER="com.mysql.jdbc.Driver";
	private DataSource dataSource=null;
	/**
	 * 创建连接池
	 * @return
	 */
	protected DataSource getDataSource(){
		if(dataSource!=null){
			return dataSource;
		}
		DruidDataSource dataSource=new DruidDataSource();
		dataSource.setUrl(URL);
		dataSource.setUsername(USERNAME);
		dataSource.setPassword(USERPASS);
		dataSource.setDriverClassName(DRIVER);
		this.dataSource=dataSource;
		return dataSource;
	}

	
}




